package com.geping.etl.common.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.geping.etl.common.entity.Sys_User;
import com.geping.etl.common.entity.User1104;
import com.geping.etl.common.service.Syn1104UserService;
import com.geping.etl.common.util.Constants;
import com.geping.etl.utils.EnvUitl;
import com.geping.etl.utils.HttpUtil;
import org.springframework.stereotype.Service;

/**
 * 同步1104用户信息
 */
@Service
public class Syn1104UserServiceImpl implements Syn1104UserService {


    public void syn1104UserInfo(Sys_User sysUser){
        User1104 user1104 = new User1104();
        user1104.setAddress(String.valueOf(sysUser.getId()));
        user1104.setLoginId(sysUser.getLoginId());
        user1104.setPassword("users123456");
        user1104.setUserEname(sysUser.getUserEname());
        user1104.setUserCname(sysUser.getUserCname());
        user1104.setOrgId(sysUser.getOrgId());
        user1104.setDepartId(sysUser.getDepartId());
        user1104.setSubjectId("30");
        user1104.setTel(sysUser.getTel());
        String body = JSONObject.toJSONString(user1104);
        String url = EnvUitl.props.getProperty(Constants.SYSTEM_1104) + "sysUser.do?actionName=synUser";
        String result = HttpUtil.postRequestAddHeaderAndRetry(url, body, null);
    }

    @Override
    public void syn1104DeleteUser(String loginId) {
        String url = EnvUitl.props.getProperty(Constants.SYSTEM_1104) + "sysUser.do?actionName=synDeleteUser";
        String result = HttpUtil.postRequestAddHeaderAndRetry(url, loginId, null);
    }


}
